<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>体验JS</title>
  <style>
    .pink {
      background-color: pink;
    }
  </style>
</head>

<body>
  
  <button id="changeColorBtn">更换背景颜色</button>

  <script>
      const colors = ['#FF5733', '#33FF57', '#3357FF', '#F1C40F', '#8E44AD','#333'];
      const button = document.getElementById('changeColorBtn');

      button.addEventListener('click', () => {
          document.body.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
      });
  </script>
</body>

</html>